package com.xiong.ai.controller;

import com.xiong.ai.exception.BusinessException;
import com.xiong.ai.result.ResBody;
import com.xiong.ai.service.AiService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;


/**
 * @program: ai
 * @description:
 * @author: Mr.熊
 * @create: 2024-05-31 10:29
 **/
@RestController
@RequestMapping("/ai")
public class AiController {

    @Resource
    private AiService aiService;

    @PostMapping("/summary")
    public ResBody<String> summary(@RequestParam(value = "file") MultipartFile file) {
        // 检查文件是否为空
        if (file.isEmpty()) {
            throw new BusinessException("文件不能为空");
        }
        String summary = aiService.getFileContent(file);
        return ResBody.ok(summary);
    }

}
